using System.Collections.Generic;

namespace Universe.OneC.DomainModel
{
    public class Namespace
    {
        public List<Namespace> Children;
        public string Name;
        public Namespace Parent;

        public Namespace(string name, Namespace parent)
        {
            this.Name = name;
            this.Parent = parent;
            if (this.Parent != null)
            {
                if (this.Parent.Children == null)
                {
                    this.Parent.Children = new List<Namespace>();
                }
                this.Parent.Children.Add(this);
            }
        }

        public Namespace Root
        {
            get
            {
                Namespace ret = this;
                Namespace ns = this;
                while (ns != null)
                {
                    ret = ns;
                    ns = ns.Parent;
                }

                return ret;
            }
        }
    }
}